import { AxiosRequestConfig } from 'axios';
import request from '@/utils/request';

/**
 * 台站列表
 * @param params
 * @returns
 */
export const fetchStations = (params: any) => {
  return request({
    url: 'stationInfo/list',
    method: 'GET',
    params,
  });
};

/**
 * 台站管理模板导出
 */
export const downloadStationTemplate = () => {
  return request({
    url: 'stationInfo/downloadTemplate',
    method: 'POST',
    responseType: 'blob',
  });
};

/**
 * 台站管理导入
 */
export const importStationTemplate = (
  data: any,
  config: AxiosRequestConfig<any>,
) => {
  return request({
    url: 'stationInfo/importData',
    method: 'POST',
    data,
    ...config,
  });
};

/**
 *
 * @param data
 * @returns
 */
export const handleChangeOperate = (data: any) => {
  return request({
    url: `stationInfo/enablePerms`,
    method: 'POST',
    data,
  });
};

/**
 * 批量导入
 */
export const importBatch = (data: any) => {
  return request({
    url: '/stationInfo/importBatch',
    method: 'POST',
    data,
  });
};

/**
 * 上传图片
 */
export const uploadImgFile = (data: any, config: AxiosRequestConfig<any>) => {
  return request({
    url: 'file/uploadOrderFile',
    method: 'POST',
    data,
    ...config,
  });
};

/**
 * 中心站
 */
export function fetchCenterStation(params: any = {}) {
  return request({
    url: '/centerStationInfo/selectList',
    method: 'get',
    params,
  });
}

/**
 * 站点类型
 * @returns
 */
export const fetchStationTypes = () => {
  return request({
    url: '/stationType/selectList',
    method: 'get',
  });
};

/**
 * 项目列表
 */
export function fetchProject() {
  return request({
    url: '/project/selectList',
    method: 'get',
  });
}

/**
 * 数采型号
 * @returns
 */
export function selectDataCollectorModel() {
  return request({
    url: '/dataCollectorModel/selectList',
    method: 'get',
  });
}

// 查询数采型号厂商
export function getDataCollectorManufacturer() {
  return request({
    url: '/manufacturer/getDataCollectorManufacturer',
    method: 'get',
  });
}

// 查询数采型号
export const fetchDataModel = (params: any) => {
  return request({
    url: 'dataCollectorModel/selectList',
    params,
  });
};

//   查询加速度计型号厂商
export function getAccelerometerModelManufacturer() {
  return request({
    url: '/manufacturer/getAccelerometerModelManufacturer',
    method: 'get',
  });
}

// 根据厂商id获取加速度计型号
export function selectAccelerometerModel(params: any) {
  return request({
    url: '/accelerometerModel/selectList',
    method: 'get',
    params,
  });
}

// 加速度计类型
export const fetchAccelerometerTypes = () => {
  return request({
    url: 'system/dict/data/type/accelerometer_model_type',
  });
};

//   查询加速度计型号厂商
export function getSpeedManufacturer() {
  return request({
    url: '/manufacturer/getSpeedometerModelManufacturer',
    method: 'get',
  });
}

// 根据厂商id获取地震计型号
export function selectSpeed(params: any) {
  return request({
    url: '/speedometerModel/selectList',
    method: 'get',
    params,
  });
}

/**
 * 地震计类型
 */
export const fetchSpeedometerModelType = () => {
  return request({
    url: 'system/dict/data/type/speedometer_model_type',
  });
};

/**
 * 智能电源厂家
 */
export function getPowerSupplyModelManufacturer() {
  return request({
    url: '/manufacturer/getPowerSupplyModelManufacturer',
    method: 'get',
  });
}

/**
 * 根据厂商id获取智能电源型号
 * @param params
 * @returns
 */
export function selectSupplyModel(params: any) {
  return request({
    url: '/powerSupplyModel/selectList',
    method: 'get',
    params,
  });
}

/**
 * 烈度计厂商
 */
export function getIntensityMeterManufacturer() {
  return request({
    url: '/manufacturer/getIntensityMeterManufacturer',
    method: 'get',
  });
}

/**
 * 获取烈度计型号
 * @param params
 * @returns
 */
export function selectIntensityMeter(params: any) {
  return request({
    url: '/intensityMeter/selectList',
    method: 'get',
    params,
  });
}

/**
 * 新增台站
 */
export const createStation = (data: any) => {
  return request({
    url: '/stationInfo/add',
    method: 'POST',
    data,
  });
};

/**
 * 删除台站
 */
export const deleteStation = (ids: number[]) => {
  return request({
    url: `stationInfo/delete/${ids.join()}`,
    method: 'DELETE',
  });
};

/**
 *
 * 更新监控状态
 */
export const changeMonitorStatus = (data: any) => {
  return request({
    url: 'stationInfo/enableMonitor',
    method: 'POST',
    data,
  });
};

/**
 * 测试烈度计IP 能否正常访问
 * @param params
 * @returns
 */
export const testIp = (params: any) => {
  return request({
    url: 'intensityInfo/testPong',
    params,
  });
};

export const testCameraIp = (params: any) => {
  return request({
    url: 'ping/testPong',
    params,
  });
};

/**
 * 导出
 */
export const exportStation = (ids: number[]) => {
  return request({
    url: 'stationInfo/exportList',
    method: 'POST',
    responseType: 'blob',
    data: {
      ids: ids.join(),
    },
  });
};

/**
 * 更新台站
 */

export const updateStation = (data: any) => {
  return request({
    url: 'stationInfo/update',
    method: 'PUT',
    data,
  });
};

/**
 * 中心站列表
 */

export function getStationList(params: any) {
  return request({
    url: '/centerStationInfo/list',
    method: 'get',
    params,
  });
}

/**
 * 编辑中心站
 */
export const updateCenterStation = (data: any) => {
  return request({
    url: '/centerStationInfo/update',
    method: 'PUT',
    data,
  });
};

/**
 * 新增中心站
 */
export const createCenterStation = (data: any) => {
  return request({
    url: 'centerStationInfo/add',
    method: 'POST',
    data,
  });
};

/**
 * 删除中心站
 */
export const deleteCenterStation = (ids: number[]) => {
  return request({
    url: `centerStationInfo/delete/${ids.join()}`,
    method: 'DELETE',
  });
};

/**
 * 厂商配置列表
 */
export const fetchManufacturerConfiguration = (params: any = {}) => {
  return request({
    url: 'manufacturer/list',
    method: 'GET',
    params,
  });
};
/**
 * 更新厂商配置
 */
export const updateManufacturerConfiguration = (data: any) => {
  return request({
    url: 'manufacturer/update',
    method: 'PUT',
    data,
  });
};
/**
 * 删除厂商配置
 */
export const deleteManufacturerConfiguration = (ids: number[]) => {
  return request({
    url: `manufacturer/delete/${ids.join()}`,
    method: 'DELETE',
  });
};

/**
 * 创建厂商配置
 */
export const createManufacturerConfiguration = (data: any) => {
  return request({
    url: `manufacturer/add`,
    method: 'POST',
    data,
  });
};

/**
 * 站点类型名称
 */
export const fetchStationTypeList = (params: any) => {
  return request({
    url: 'stationType/list',
    method: 'GET',
    params,
  });
};

/**
 * 站点类型树
 * @param data
 * @returns
 */
export const fetchStationTypeTree = () => {
  return request({
    url: 'stationType/selectTreeList',
  });
};

/**
 * 新增站点类型
 */
export const createStationType = (data: any) => {
  return request({
    url: 'stationType/add',
    method: 'POST',
    data,
  });
};

/**
 * 更新站点类型
 */
export const updateStationType = (data: any) => {
  return request({
    url: 'stationType/update',
    method: 'PUT',
    data,
  });
};
/**
 * 删除站点类型
 */
export const deleteStationType = (ids: number[]) => {
  return request({
    url: `stationType/delete/${ids.join()}`,
    method: 'DELETE',
  });
};

/**
 * 数采型号名称
 */
export const fetchDataModelList = (params?: any) => {
  return request({
    url: 'dataCollectorModel/list',
    method: 'GET',
    params,
  });
};

/**
 * 新增数采型号
 */
export const createDataModel = (data: any) => {
  return request({
    url: 'dataCollectorModel/add',
    method: 'POST',
    data,
  });
};

/**
 * 更新数采型号
 */
export const updateDataModel = (data: any) => {
  return request({
    url: 'dataCollectorModel/update',
    method: 'PUT',
    data,
  });
};
/**
 * 删除数采型号
 */
export const deleteDataModel = (ids: number[]) => {
  return request({
    url: `dataCollectorModel/delete/${ids.join()}`,
    method: 'DELETE',
  });
};

/**
 * 台站树
 */
export const fetchStationTree = () => {
  return request({
    url: '/stationInfo/leftTree',
  });
};

/***********************************智能电源***********************************/
/**
 * 查询智能电源列表
 */
export function getPowerList(params: any) {
  return request({
    url: '/powerSupplyModel/list',
    method: 'get',
    params,
  });
}

/**
 * 查询厂商名称
 * @returns
 */
export function getManufacturerList() {
  return request({
    url: '/manufacturer/selectList',
    method: 'get',
  });
}

/**
 * 新增智能电源
 */
export function createPower(data: any) {
  return request({
    url: '/powerSupplyModel/add',
    method: 'POST',
    data,
  });
}

/**
 * 修改智能电源
 */
export function updatePower(data: any) {
  return request({
    url: '/powerSupplyModel/update',
    method: 'PUT',
    data,
  });
}

/**
 * 删掉智能电源
 */

export function deletePower(ids: number[]) {
  return request({
    url: `/powerSupplyModel/delete/${ids.join()}`,
    method: 'DELETE',
  });
}

/***********************************加速度计***********************************/
/**
 * 查询加速度计列表
 */
export function getAccelerometerList(params: any) {
  return request({
    url: '/accelerometerModel/list',
    method: 'get',
    params,
  });
}

/**
 * 查询加速度计列表类型字典
 */
export function getAccelerometerTypeDict() {
  return request({
    url: '/system/dict/data/type/accelerometer_model_type',
    method: 'get',
  });
}

/**
 * 新增加速度计
 */
export function createAccelerometer(data: any) {
  return request({
    url: '/accelerometerModel/add',
    method: 'POST',
    data,
  });
}

/**
 * 修改加速度计
 */
export function updateAccelerometer(data: any) {
  return request({
    url: '/accelerometerModel/update',
    method: 'PUT',
    data,
  });
}

/**
 * 删掉加速度计
 */
export function deleteAccelerometer(ids: number[]) {
  return request({
    url: `/accelerometerModel/delete/${ids.join()}`,
    method: 'DELETE',
  });
}

/***********************************地震计***********************************/
/**
 * 查询地震计列表
 */
export function getSpeedList(params: any) {
  return request({
    url: '/speedometerModel/list',
    method: 'get',
    params,
  });
}

/**
 * 查询地震计列表类型字典
 */
export function getSpeedTypeDict() {
  return request({
    url: '/system/dict/data/type/speedometer_model_type',
    method: 'get',
  });
}

/**
 * 新增地震计
 */
export function createSpeed(data: any) {
  return request({
    url: '/speedometerModel/add',
    method: 'POST',
    data,
  });
}

/**
 * 修改地震计
 */
export function updateSpeed(data: any) {
  return request({
    url: '/speedometerModel/update',
    method: 'PUT',
    data,
  });
}

/**
 * 删掉地震计
 */
export function deleteSpeed(ids: number[]) {
  return request({
    url: `/speedometerModel/delete/${ids.join()}`,
    method: 'DELETE',
  });
}

/***********************************烈度计***********************************/
/**
 * 查询烈度计列表
 */
export function getIntensityList(params?: any) {
  return request({
    url: '/intensityMeter/list',
    method: 'get',
    params,
  });
}

/**
 * 新增烈度计
 */
export function createIntensity(data: any) {
  return request({
    url: '/intensityMeter/add',
    method: 'POST',
    data,
  });
}

/**
 * 修改烈度计
 */
export function updateIntensity(data: any) {
  return request({
    url: '/intensityMeter/update',
    method: 'PUT',
    data,
  });
}

/**
 * 删掉烈度计
 */
export function deleteIntensity(ids: number[]) {
  return request({
    url: `/intensityMeter/delete/${ids.join()}`,
    method: 'DELETE',
  });
}

/**
 * 云台控制
 */
export function PtzControl(up: any, params: any) {
  const { baseURL, deviceId, channelId } = up;
  return request({
    baseURL,
    url: `/api/ptz/control/${deviceId}/${channelId}`,
    method: 'POST',
    params,
  });
}

/**
 * 数据通道获取
 */

export function getselectSource(params?: any) {
  return request({
    url: 'tdInfo/selectSource',
    method: 'get',
    params,
  });
}

/**
 * 台网管理--列表
 */
export const fetchNetworks = (params: any) => {
  return request({
    url: 'networkInfo/list',
    method: 'GET',
    params,
  });
};

/**
 * 台网管理--删除
 */
export const deleteNetworks = (ids: number[]) => {
  return request({
    url: `networkInfo/delete/${ids.join()}`,
    method: 'DELETE',
  });
};

/**
 * 台网管理-- 新增
 */
export const createNetwork = (data: any) => {
  return request({
    url: 'networkInfo/add',
    method: 'POST',
    data,
  });
};

/**
 * 台网管理--修改
 */
export const updateNetwork = (data: any) => {
  return request({
    url: 'networkInfo/update',
    method: 'PUT',
    data,
  });
};

/**
 * 告警联系人
 */
export function fetchTotalUserName() {
  return request({
    url: '/deptUser/selectList',
  });
}

/**
 * 批量入退网
 */
export function batchOnlineStation(data: any) {
  return request({
    url: 'stationInfo/batchOlineStation',
    method: 'post',
    data,
  });
}

/** ================ 仓库管理 ================== */

/**
 * 仓库列表
 * @param params
 * @returns
 */
export const fetchWarehouses = (params: any) => {
  return request({
    url: `warehouseInfo/list`,
    params,
  });
};

/**
 * 新增仓库
 * @param data
 * @returns
 */
export const cerateWarehouse = (data: any) => {
  return request({
    url: 'warehouseInfo/add',
    method: 'POST',
    data,
  });
};

/**
 * 更新仓库
 * @param data
 * @returns
 */
export const updateWarehouse = (data: any) => {
  return request({
    url: 'warehouseInfo/update',
    method: 'PUT',
    data,
  });
};

/**
 * 删除仓库
 * @param ids
 * @returns
 */
export const deleteWarehouse = (ids: (number | string)[]) => {
  return request({
    url: `/warehouseInfo/delete/${ids.join()}`,
    method: 'DELETE',
  });
};

/** ================ 设备信息 ================== */

/**
 * 设备信息列表
 * @param params
 * @returns
 */
export const fetchDeviceInfoList = (params: any) => {
  return request({
    url: `deviceInfo/list`,
    params,
  });
};

/**
 * 创建设备信息
 * @param data
 * @returns
 */
export const createDeviceInfo = (data: any) => {
  return request({
    url: `deviceInfo/add`,
    method: 'POST',
    data,
  });
};

/**
 * 修改设备信息
 * @param data
 * @returns
 */
export const updateDeviceInfo = (data: any) => {
  return request({
    url: `deviceInfo/update`,
    method: 'PUT',
    data,
  });
};

/**
 * 修改设备灵敏度
 * @param data
 * @returns
 */
export const updateDeviceSensitivity = (data: any) => {
  return request({
    url: `deviceInfo/updateSensitivity`,
    method: 'PUT',
    data,
  });
};

/**
 * 删除设备信息
 * @param data
 * @returns
 */
export const deleteDeviceInfo = (ids: (string | number)[]) => {
  return request({
    url: `deviceInfo/delete/${ids.join()}`,
    method: 'DELETE',
  });
};

/**
 * 设备导入模板
 * @returns
 */
export const downloadDeviceInfoTemplate = () => {
  return request({
    url: 'deviceInfo/downloadTemplate',
    responseType: 'blob',
    method: 'POST',
  });
};

/**
 * 解析导入 excel 数据
 * @param data
 * @param config
 * @returns
 */
export const analyzeDeviceInfoTemplate = (
  data: any,
  config: AxiosRequestConfig<any>,
) => {
  return request({
    url: 'deviceInfo/importData',
    method: 'POST',
    data,
    ...config,
  });
};

/**
 * 批量导入设备信息
 * @param data
 * @returns
 */
export const importBatchDevice = (data: any) => {
  return request({
    url: `deviceInfo/importBatch`,
    method: 'POST',
    data,
  });
};

/**
 * 导出设备信息
 * @param data
 * @returns
 */
export const exportBatchDevice = (data: any) => {
  return request({
    url: 'deviceInfo/exportList',
    method: 'POST',
    responseType: 'blob',
    data,
  });
};

/**
 * 设备库存查询
 * @param params
 * @returns
 */
export const fetchDeviceStock = (params: any) => {
  return request({
    url: `deviceInfo/getInventorylist`,
    params,
  });
};

/**
 * 设备库存详情
 * @returns
 */
export const fetchDeviceStockDetail = (params: any) => {
  return request({
    url: 'deviceInfo/getInventoryDetail',
    params,
  });
};

/** ================ 设备入库 ================== */

/**
 * 设备入库列表
 * @param params
 * @returns
 */
export const fetchInbound = (params: any) => {
  return request({
    url: 'deviceStorage/list',
    params,
  });
};

/**
 * 新增设备入库
 * @param params
 * @returns
 */
export const createInbound = (data: any) => {
  return request({
    url: 'deviceStorage/add',
    method: 'POST',
    data,
  });
};

/**
 * 删除设备入库
 * @param params
 * @returns
 */
export const deleteInbound = (ids: any) => {
  return request({
    url: `deviceStorage/delete/${ids.join()}`,
    method: 'DELETE',
  });
};

export const fetchInAndOutBound = (params: any) => {
  return request({
    url: 'deviceStorage/getInOutlist',
    params,
  });
};

/** ================ 设备出库 ================== */

/**
 * 设备出库列表
 * @param params
 * @returns
 */
export const fetchOutbound = (params: any) => {
  return request({
    url: `deviceOutbound/list`,
    params,
  });
};

/**
 * 创建设备出库
 * @param data
 * @returns
 */
export const createOutbound = (data: any) => {
  return request({
    url: 'deviceOutbound/add',
    method: 'POST',
    data,
  });
};

/**
 * 删除设备出库
 * @param id
 * @returns
 */
export const deleteOutbound = (ids: number[]) => {
  return request({
    url: `deviceOutbound/delete/${ids.join()}`,
    method: 'DELETE',
  });
};

export const fetchDeviceInventoryList = (params: any) => {
  return request({
    url: 'deviceInfo/getDeviceInventoryList',
    params,
  });
};

/**
 * 台站噪音
 */
export const fetchNoiseMonitoring = (params: any) => {
  return request({
    url: 'stationInfo/getNoiseMonitoring',
    params,
  });
};

/**
 * 生成噪音图片
 */
export const generateNoise = (data: any) => {
  return request({
    url: `stationInfo/generateNoise`,
    method: 'POST',
    data,
  });
};
